package com.kaichaohulian.baocms.adapter;

import android.content.Intent;
import android.graphics.Color;
import android.view.View;

import com.chad.library.adapter.base.BaseQuickAdapter;
import com.chad.library.adapter.base.BaseViewHolder;
import com.kaichaohulian.baocms.R;
import com.kaichaohulian.baocms.activity.HelpAlreadyPaylActivity;
import com.kaichaohulian.baocms.activity.HelpQuDetailActivity;
import com.kaichaohulian.baocms.newmodel.FaBuModel;

import java.util.List;

/**
 * Created by gaoyuan on 2017/5/4.
 */

public class FaBuAdapter extends BaseQuickAdapter<FaBuModel.DataObjectBean, BaseViewHolder> {
    public FaBuAdapter(List<FaBuModel.DataObjectBean> data) {
        super(R.layout.item_fabu, data);
    }

    @Override
    protected void convert(BaseViewHolder helper, final FaBuModel.DataObjectBean item) {

        helper.setText(R.id.text_title, item.getTitle());
        helper.setText(R.id.text_time, item.getCreatedTime());
        if (item.getType().equals("1")) {
            helper.setImageResource(R.id.img_purchase, R.mipmap.mai);
        } else if (item.getType().equals("2")) {
            helper.setImageResource(R.id.img_purchase, R.mipmap.qu);
        } else if (item.getType().equals("3")) {
            helper.setImageResource(R.id.img_purchase, R.mipmap.song);
        }
        if (item.getType().equals("4")) {
            helper.setImageResource(R.id.img_purchase, R.mipmap.fu);
        } else if (item.getType().equals("5")) {
//         排队   pai
            helper.setImageResource(R.id.img_purchase, R.mipmap.pai);
        } else if (item.getType().equals("6")) {
            //其他需求
            helper.setImageResource(R.id.img_purchase, R.mipmap.xu);
        } else if (item.getType().equals("7")) {
            //顺
            helper.setImageResource(R.id.img_purchase, R.mipmap.shun);

        } else if (item.getType().equals("8")) {
            //代
            helper.setImageResource(R.id.img_purchase, R.mipmap.dai);

        } else if (item.getType().equals("9")) {
//预
            helper.setImageResource(R.id.img_purchase, R.mipmap.yu);
        } else if (item.getType().equals("10")) {
            //共
            helper.setImageResource(R.id.img_purchase, R.mipmap.gong);

        } else {

        }
        if (item.getStatus().equals("0")) {
            helper.setText(R.id.text_status, "发布");
            helper.setTextColor(R.id.text_status, Color.parseColor("#fd6e01"));
        } else if (item.getStatus().equals("1")) {
            helper.setText(R.id.text_status, "进行中");
            helper.setTextColor(R.id.text_status, Color.parseColor("#c8d506"));
        } else if (item.getStatus().equals("2")) {
            helper.setText(R.id.text_status, "完成");
            helper.setTextColor(R.id.text_status, Color.parseColor("#fd6e01"));
        } else if (item.getStatus().equals("3")) {
            helper.setText(R.id.text_status, "已评价");
            helper.setTextColor(R.id.text_status, Color.parseColor("#78bf69"));
        } else if (item.getStatus().equals("4")) {
            helper.setText(R.id.text_status, "申请退款");
        } else if (item.getStatus().equals("5")) {
            helper.setText(R.id.text_status, "同意退款");
            helper.setTextColor(R.id.text_status, Color.parseColor("#af02e2"));
        } else if (item.getStatus().equals("6")) {
            helper.setText(R.id.text_status, "拒绝退款");
            helper.setTextColor(R.id.text_status, Color.parseColor("#2c00ff"));
        } else if (item.getStatus().equals("7")) {
            helper.setText(R.id.text_status, "提交申请完成");
            helper.setTextColor(R.id.text_status, Color.parseColor("#2c00ff"));
        }

        helper.setText(R.id.text_money, item.getUserApplyCount() + "人申请中");
        View view = helper.getConvertView();
        view.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                Intent intent = new Intent();
                intent.putExtra("type", item.getType());
                if (item.getStatus().equals("0")) {
                    intent.setClass(mContext, HelpAlreadyPaylActivity.class);
                } else if (item.getType().equals("2")) {
                    intent.setClass(mContext, HelpQuDetailActivity.class);
                } else {
                    intent.setClass(mContext, HelpQuDetailActivity.class);
                }

                intent.putExtra("type", item.getType());
                intent.putExtra("demandId", item.getId());
                mContext.startActivity(intent);
            }
        });

    }


}
